<script type="text/javascript" src="{lib file=jquery.plugins/jquery.validate.js}" charset="utf-8"></script>
<script type="text/javascript">
function submitData()
{
	var content = $('#content').val();
	var captcha = $('#captcha2').val();
	var email = $('#email').val();
	var checked = $('#hide_name').prop('checked');
	var hide_name = checked ? $('#hide_name').val() : "";
	var captchaEnable = <!--{if $captcha}-->true<!--{else}-->false<!--{/if}-->;
	if(captchaEnable == false)
	{
		errormsg("{$lang.open_captcha_pls}");
	}
	else
	{
		if(content == "")
		{
			errormsg('{$lang.content_not_null}');
		}
		else
		{
			if(checkEmail(email) == false)
			{
				errormsg("{$lang.email_invalid}");
			}
			else
			{
				if(captcha == "")
				{
					errormsg("{$lang.captcha_required}");
				}
				else
				{
					var ca_url =REAL_SITE_URL+"/index.php?app=captcha&act=check_captcha";
					$.getJSON(ca_url,{captcha:captcha},function(data){
							if(data==false){
								errormsg("{$lang.captcha_error}");
							}
							else
							{ 
								var url = REAL_SITE_URL+"/index.php?app=goods&act=qa&id={$smarty.get.id}";
								$.post(url,{content:content,captcha:captcha,email:email,hide_name:hide_name},function(data){
									if(data == true){
										msg('{$lang.qa_success}');
										setTimeout(function(){
											window.location.href= REAL_SITE_URL+"/index.php?app=goods&act=qa&id={$smarty.get.id}";
										},1500);
									}  
								},"json");
							}
					});
				}
			}
		}	
	}
}
</script>

<div class="qas padding10">
    <!--{foreach from=$qa_info item=qainfo name=fe_qa}-->
    <div  class="list">
    	<div {if $smarty.foreach.fe_qa.last}style="border:0px;"{/if} class="it">
            <dl>
                <dt>{$lang.question_content}: </dt>
                <dd class="qa-content mt5">{$qainfo.question_content|escape|nl2br}</dd>
                <p class="mt5 w-full clearfix">
                    <span><!-- {if $qainfo.user_name} -->{$qainfo.user_name}<!--{else}-->{$lang.guest}<!-- {/if} --></span><em>{$qainfo.time_post|date:complete}</em>
                </p>
            </dl>
            <!-- {if $qainfo.reply_content} -->
            <dl class="mt10"> 
                <dt class="store-replay">{$lang.store_reply}: </dt>
                <dd class="mt5">{$qainfo.reply_content|escape|nl2br}</dd>
                <p class="mt5">
                    <span>{$qainfo.time_reply|date:complete}</span>
                </p>
            </dl>
            <!-- {/if} -->
        </div>
    </div>
    <!-- {foreachelse} -->
    <div class="list padding10">{$lang.no_records}</div>
    <!--{/foreach}-->
    {if $qa_info}{include file=page.bottom.html}{/if}
</div>
<!--{if $smarty.get.app eq 'goods'}-->
<div class="fill_in pl10 pr10 pb10">
    <p><textarea name="content" id="content" class="input textarea"   placeholder="我要咨询"></textarea></p>
    <p>
        <!--{if !$guest_comment_enable and !$visitor.user_id}-->
            {$lang.login_to_comment}
        <!--{else}-->
        <span><input type="text" class="input" id="email" name="email" value="{$email}"  placeholder="请输入电子邮箱"/></span>
        <!--{if $captcha}-->
        <span><input type="text" class="input captcha" id="captcha2" name="captcha" placeholder="请输入验证码"/></span>
        <span><a href="javascript:;"><img id="captcha" onclick="javascript:change_captcha($('#captcha'));"  src="{$site_url}/mobile/index.php?app=captcha&amp;{$random_number}" /></a></span>
        <!--{/if}-->
        <!--{if $smarty.session.user_info}-->
        <span><label><input type="checkbox" name="hide_name" id="hide_name" value="hide" /> {$lang.hide_name}</label></span>
        <!--{/if}-->
        <!--{/if}-->
    </p>
    <p>
    	<input type="button" onclick="submitData();" value="{$lang.submit_message}" name="qa" class="enter"/>
    </p>
    </form>
</div>
<!--{/if}-->
